﻿
namespace PlottingBasics.Functions
{
    public static class Helpers
    {
        /// <summary>
        /// Calculates the fractional distance between two points.
        /// </summary>
        /// <param name="low"></param>
        /// <param name="high"></param>
        /// <param name="val"></param>
        /// <returns></returns>
        public static double FractionBetween (double low, double high, double val)
        {
            double range = high - low;
            if (range == 0)
            {
                return 0.0;
            }
            double frac = (val - low) / range;
            return frac;
        }

        /// <summary>
        /// Given a fraction in, assuming 1.0 is the delta, this will...
        /// </summary>
        /// <param name="p"></param>
        /// <param name="p_2"></param>
        /// <param name="fraction"></param>
        /// <returns></returns>
        public static double CalcFractionBetween (double low, double high, double fraction)
        {
            return (high - low) * fraction + low;
        }
    }
}
